package com.hmall.common.interceptors;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
//@Component
public class MyFeignInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        log.info("feign拦截器,设置请求头authorization=2");
        template.header("authorization","2");
        
        //动态获取请求数据(注意:测试时需要通过浏览器访问订单接口 http://localhost:10010/order/123865420)
//        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request = attributes.getRequest();
//        String authorization = request.getHeader("authorization");
//        System.out.println("authorization=" + authorization);
    }
}